﻿<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/js/themes/icon.css">
<script type="text/javascript" src="<%=path%>/js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.easyui.min.js"
	charset="utf-8"></script>
<script type="text/javascript" src="<%=path%>/js/locale/easyui-lang-zh_CN.js"
	charset="utf-8"></script>
<script type="text/javascript" src="<%=path%>/js/datagrid-filter.js"
	charset="utf-8"></script>
<script type="text/javascript">
	$(function(){
		var abc = new Array();
		var das ="";
	 	var sizes =new Array();
	 	var merges = [{
            index:0,
            rowspan:1
			          }];
		 $.ajax({
			  
	           type: "GET",
	           url:'<%=path%>/main/get/cb',
	          
			   data : {
				         "cropid":<%=session.getAttribute("cropid")%>,
				          pageSize: 10,
				    	  pageNumber: 1
					},
						async : false,
						success : function(data) {
							var data = eval('(' + data + ')');
							das=data.data.rows;
							sizes=data.data.sizes;
							lsh =data.data.lsh;
						console.log(lsh.length);
						console.log(sizes.length);
							for(var i=0;i<sizes.length;i++){
								
								merges.push(sizes[i]);
								abc.push(merges[i],lsh[i]);
						console.log(abc[i]);
							}
							
						   }

					}); 
		 
		 
	 	 var dg = $('#tt').datagrid({
	 		 	height:800,
	 /* 		 	remoteFilter:true,
	 		 	filterRules:[
	 		 	            
	 		 	             ],
	 		 	filterStringify:function(data){
	 		 		console.info(data+"#");
	 				var s=JSON.stringify(data);
	 		 		console.log(s);
	 		 	}, */
				filterBtnIconCls:'icon-filter',		
		        data:das,
				columns:[[
			                {field:'lsh',title:'流水号',width:100,hidden:false},      
							{field:'date', title:'日期',width:100},
							{field:'shoushudoc',title:'手术医师',width:100},
							{field:'peitai',title:'配台医师',width:100},
							{field:'feishoushu',title:'非手术医师',width:100},
							{field:'cusname',title:'顾客姓名',width:100},
							{field:'xczx',title:'现场咨询',width:100},
							{field:'webzx',title:'网络咨询',width:100},
							{field:'phonezx',title:'电话咨询',width:100},
							{field:'scb',title:'市场部',width:100},
							{field:'menzhen',title:'门诊',width:100},
							{field:'qita',title:'其他',width:100},
							{field:'membername',title:'会员名称',width:100},
							{field:'xfdl',title:'消费大类',width:100},
							{field:'xmfl',title:'项目分类',width:100},
							{field:'xfmx',title:'消费明细',width:100},
							{field:'jfje',title:'应缴费金额',width:100},
							{field:'sjje',title:'实际消费金额',width:100},
						    {field:'zhekopulv',title:'折扣率',width:100},
							{field:'youhuijine',title:'优惠金额',width:100},
							{field:'cash',title:'现金',width:100},
							{field:'shuaka',title:'刷卡pos',width:100},
							{field:'zhipiao',title:'支票',width:100},			
							{field:'dianhui',title:'电汇',width:100},				
							{field:'qiankuan',title:'欠款',width:100},
							{field:'huaka',title:'划卡',width:100},
							{field:'yajintrans',title:'押金转入',width:100},
							{field:'beiyong1',title:'美尔贝',width:100},
							{field:'beiyong2',title:'诺美尔',width:100},
			                {field:'yimei',title:'依美网',width:100},
							{field:'dongfang',title:'东方虹',width:100},
						    {field:'ailibang',title:'爱立邦',width:100},
							{field:'gengmei',title:'更美',width:100},
							{field:'xinyang',title:'新氧',width:100},
							{field:'yuemei',title:'悦美',width:100},
							{field:'zhenyoumei',title:'真优美',width:100},
							{field:'fuka',title:'福卡',width:100},
							{field:'beiyong',title:'服务项目',width:100},
							{field:'otherpay',title:'其他付款',width:100},
							{field:'yfcrop',title:'应付公司',width:100},
							{field:'otherrecive',title:'其他应收',width:100},
							{field:'yscrop',title:'应收公司',width:100},
							{field:'yuyuedate', title:'预约金时间',width:100},
							{field:'bankadate', title:'办卡时间',width:100},
							{field:'fapiaohao',title:'发票号',width:100},
							{field:'beizhu',title:'备注',width:100},
							{field:'chukudan',title:'出库单',width:100},
							{field:'shoukuanren',title:'收款人',width:100},	
							{field:'fssbz',title:'非手术备注',width:100}
							  ]],
				onLoadSuccess:function(){
						
					var rows =  $("#tt").datagrid("getRows");
					
					 $.ajax({
						  
				           type: "GET",
				           url:'<%=path%>/main/get/cb',				          
						   data : {
							         "cropid":<%=session.getAttribute("cropid")%>,
							          pageSize: 10,
							    	  pageNumber: 1
								},
									async : false,
									success : function(data) {
										var data = eval('(' + data + ')');
										das=data.data.rows;
										sizes=data.data.sizes;
										
										for(var i=0;i<sizes.length;i++){
											merges.push(sizes[i]);
										}
										
									   }

								});
					
				
		 				 var merge = merges;
		 				    
							for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'cash',
									rowspan:merges[i].size,
									
								});
							 }
							for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'shuaka',
									rowspan:merges[i].size,
									
								});
							 }
							for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'zhipiao',
									rowspan:merges[i].size,
									
								});
							 }for(var i=1; i<merges.length; i++)
							 {
									
									$('#tt').datagrid('mergeCells',{
										
										index:merge[i].index,
										field:'dianhui',
										rowspan:merges[i].size,
										
									});
								 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'qiankuan',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'huaka',
									rowspan:merges[i].size,
									
								});
							 }
							 
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'beiyong1',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'beiyong2',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yimei',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'dongfang',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'ailibang',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'gengmei',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'xinyang',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yuemei',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'zhenyoumei',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yajintrans',
									rowspan:merges[i].size,
									
								});
							 }
						
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'fuka',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'otherpay',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'otherrecive',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yfcrop',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yscrop',
									rowspan:merges[i].size,
									
								});
							 }
						} 
			});
		/*  //设置分页控件  
	    var p = $('#tt').datagrid('getPager');  
	    $(p).pagination({  
	        pageSize: 10,//每页显示的记录条数，默认为10  
	        pageList: [10,15,20,25],//可以设置每页记录条数的列表  
	        beforePageText: '第',//页数文本框前显示的汉字  
	        afterPageText: '页    共 {pages} 页',  
	        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
	    }); */
	    dg.datagrid('enableFilter', [{
			field:'jfje',
			type:'text',
			
			op:['equal','notequal','less','greater']
		},{
			field:'sjje',
			type:'text',
			
			op:['equal','notequal','less','greater']
		}
		]); 

  
	    
	});
	</script>

<script type="text/javascript">
    function create(){
 	 
 	  var rows=  $('#tt').datagrid('getChecked');
 	  var params="";
 	  
 	  $.each(rows, function(index, row){
 	
 		  params+=row.lsh+",";
 			});
 	  
 	     $.ajax({
 		           type: "POST",
 		           url:"<%=path%>/main/create/excel",
 				   data : {
 	   		       "cropid":<%=session.getAttribute("cropid")%>,
 				   "params":params,
 	   				 },
 					async : false,
 					success : function(data) {
 				
 					var data = eval('(' + data + ')');
 					var num = data.data.status;
 			
 					if (num == 0) {
 	                  $.messager.alert("","成功创建excle");
 	                     
 					 }
 					if (num == 1) {
 	 	                  $.messager.alert("","再试一次吧!");
 	 	                     
 	 					 }

 				}
 		}); 
    }
  

</script>
<style>
#d1 {
	text-align: center;
}

#d3 {
	width: 100%;
	margin: 45px auto;
}
#searchform table td{ word-break:break-all; padding:5px 0;}
</style>
<title>Insert title here</title>
</head>
<body>
	<div id="d1">
		<h2>公司台账</h2>
	</div>



	<div id="d3">
	    <input type="button" id="excel" value="生成excel" onclick="create()">
		<table id="tt">

		</table>
		
	</div>


</body>
</html>